package com.agg.core.base.po;

import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;

import java.util.Date;

public class Entity {
    @TableField(fill = FieldFill.INSERT)
    private Object createId;
    @TableField(fill = FieldFill.UPDATE)
    private Object updateId;
    @TableField(fill = FieldFill.INSERT)
    private Date createTime;
    @TableField(fill = FieldFill.UPDATE)
    private Date updateTime;

    @TableField(exist = false)
    private String  vobjId;

    @TableLogic
    @TableField(fill = FieldFill.INSERT)
    //逻辑删除状态，1：有效，2：删除
    private Integer enabled;

    public Entity allEx() {
        Date times = DateUtil.date();

        setUpdateTime(times);
        setCreateTime(times);
        this.createId = "0";
        this.updateId ="0";

        this.enabled = 1;
        return this;
    }

    public Entity allEx(Object userId) {
        Date times = DateUtil.date();
        setCreateTime(times);
        setCreateId(userId);
        this.enabled = 1;
        return this;
    }

    public Entity allTime() {
        Date times = DateUtil.date();
        setUpdateTime(times);
        setCreateTime(times);
        return this;
    }

    public Entity created(String userId) {
        setCreateTime(DateUtil.date());
        setCreateId(userId);
        this.enabled = 1;
        return this;
    }

    public Entity updated(String userId) {
        setUpdateTime(DateUtil.date());
        setUpdateId(userId);
        return this;
    }

    public Entity disable(String userId) {
        setUpdateTime(DateUtil.date());
        setUpdateId(userId);
        this.enabled = 2;
        return this;
    }

    public void setVobjId(String id){
        this.vobjId=id;
    }
    public String getVobjId(){
        return this.vobjId;
    }


    public Object getCreateId() {
        return createId;
    }

    public void setCreateId(Object createId) {
        this.createId = createId;
    }

    public Object getUpdateId() {
        return updateId;
    }

    public void setUpdateId(Object updateId) {
        this.updateId = updateId;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public Integer getEnabled() {
        return enabled;
    }

    public void setEnabled(Integer enabled) {
        this.enabled = enabled;
    }
}
